package com.imooc.mall.model.controller;

import com.github.pagehelper.PageInfo;
import com.imooc.mall.model.common.ApiRestResponse;
import com.imooc.mall.model.pojo.Product;
import com.imooc.mall.model.request.ProductListReq;
import com.imooc.mall.model.service.CategoryService;
import com.imooc.mall.model.service.ProductService;
import com.imooc.mall.model.vo.CategoryVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 前端商品功能
 */
@RestController
public class ProductController {

    @Autowired
    ProductService productService;

    @ApiOperation("前端商品详情")
    @GetMapping("product/detail")
    public ApiRestResponse detail(@RequestParam Integer id){
        Product product = productService.detail(id);
        return ApiRestResponse.success(product);
    }

    @ApiOperation("前端查询")
    @GetMapping("product/list")
    public ApiRestResponse list( ProductListReq productListReq){
        PageInfo pageInfo = productService.list(productListReq);
        return ApiRestResponse.success(pageInfo);
    }

}
